<template>
	<view class="container">
		<view class="container-c">
			<!-- 已登录的显示 -->
			<view class="top" v-if="isLogin==true">
				<image class="left" src="/static/logo.png" mode="" @tap="goUserInfo"></image>
				<view class="right">
					<view class="name">
						{{user.nickname}}
					</view>
					<view class="phono">
						用户名:{{user.username}}
					</view>
				</view>
			</view>
			<!-- 未登录的显示 -->
			<view class="nologin" v-else>
				<view class="top">
					<view class="left" @tap="goUserInfo">

					</view>
					<view class="right">
						<view class="name">
							Hi~
						</view>
						<view class="phono">
							您还木有登录呢
						</view>
					</view>
				</view>
				<view class="btn">
					<view @tap="doRegister"  class="register">
						注册
					</view>
					<view @tap="goLog" class="login">
						登录
					</view>
				</view>
			</view>
			<!-- 我的订单 -->
			<view class="order">
				<view class="title" @tap="goOrderType(0)">
					我的订单
				</view>
				<view class="tab">
					<view class="item" @tap="goOrderType(0)">
						<image src="../../static/icons/icon-pay.png" mode=""></image>
						<text>待付款</text>
					</view>
					<view class="item" @tap="goOrderType(1)">
						<image src="../../static/icons/pay-done.png" mode=""></image>
						<text>已付款</text>
					</view>
					<view class="item" @tap="goOrderType(2)">
						<image src="../../static/icons/card.png" mode=""></image>
						<text>已发货</text>
					</view>
					<view class="item" @tap="goOrderType(3)">
						<image src="../../static/icons/icon-done.png" mode=""></image>
						<text>已收货</text>
					</view>
					<view class="item" @tap="goOrderType(4)">
						<image src="../../static/icons/icon-back.png" mode=""></image>
						<text>售后</text>
					</view>
				</view>
			</view>
			<!-- 底部 -->
			<view class="bottom">
				<view class="item">
					<image src="../../static/icons/save.png" mode=""></image>
					<text>商品收藏</text>
				</view>
				<view class="item">
					<image src="../../static/icons/brand.png" mode=""></image>
					<text>品牌</text>
				</view>
				<view class="item">
					<image src="../../static/icons/article.png" mode=""></image>
					<text>文章收藏</text>
				</view>
				<view class="item" @tap="goAddressList">
					<image src="../../static/icons/address.png" mode=""></image>
					<text>地址</text>
				</view>
				<view class="item">
					<image src="../../static/icons/card.png" mode=""></image>
					<text>卡包</text>
				</view>
				<view class="item" @tap="goCart">
					<image src="../../static/icons/cart2.png" mode=""></image>
					<text>购物车</text>
				</view>
				<view class="item">
					<image src="../../static/icons/kf.png" mode=""></image>
					<text>联系客服</text>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import goLogin from "@/mixins/isLogin.js";
	export default {
		data() {
			return {
				isLogin: false,
				user:{}
			};
		},
		methods:{
			goOrderType(type){
				uni.navigateTo({
					url:"/pages/mine/myOrder/myOrder?type="+type
				})
				},
			goLog(){
				uni.navigateTo({
					url:"/pages/mine/login/login"
				})
			},
			doRegister(){
				uni.navigateTo({
					url:"/pages/mine/register/register"
				})
			},
			goUserInfo(){
				uni.navigateTo({
					url:"/pages/mine/userinfo/userinfo"
				})
			},
			goCart(){
				uni.navigateTo({
					url:"/pages/mine/cart/cart"
				})
			},
			goAddressList(){
				uni.navigateTo({
					url:"../list/address/address"
				})
			}
		},
		mixins: [goLogin],
		onShow() {
				console.log(uni.getStorageSync("userInfo"))
			this.goLogin();
			var token = uni.getStorageSync("token");
			if (token) {
				this.isLogin = true;
				this.user=uni.getStorageSync("userInfo")
			
			} else {
				this.isLogin = false;
			}
		},
		onLoad() {
			// this.userInfo=uni.getStorageInfoSync("userInfo")
			
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		width: 100%;
		background-color: #f1ece7;
		height: 100vh;
	}

	.container-c {
		width: 670rpx;
		margin: 0 auto;
	}
	.nologin{
		.btn{
			display: flex;
			align-items: center;
			justify-content: center;
			margin-top: 40rpx;
			.register{
				width: 182rpx;
				height: 76rpx;
				border-radius: 10rpx;
				border: 2rpx solid #354e44;
				font-size: 30rpx;
				line-height: 76rpx;
				text-align: center;
				color: #354e44;
				margin-right: 60rpx;
			}
			
			.login{
				font-size: 30rpx;
				line-height: 76rpx;
				text-align: center;
				width: 182rpx;
				height: 76rpx;
				border-radius: 10rpx;
				background-color: #354e44;
				color: #FFFFFF;
			}
		}
	}
	
	.top {
		padding-top: 60rpx;
		display: flex;
		align-items: center;

		.left {
			width: 150rpx;
			height: 150rpx;
			border-radius: 50%;
			background-color: #354e44;
		}

		.right {
			margin-left: 30rpx;

			.name {
				font-size: 40rpx;
				font-weight: 600;
			}

			.phono {
				font-size: 26rpx;
				color: #999;
				margin-top: 20rpx;
			}
		}
	}

	.order {
		background-color: #fff;
		border-radius: 4rpx;
		padding: 20rpx 50rpx;
		margin-top: 60rpx;

		.title {
			border-bottom: 1px solid #ddd;
			padding-bottom: 20rpx;
			font-size: 26rpx;
		}
	}

	.tab {
		display: flex;
		align-items: center;
		justify-content: space-between;

		.item {
			display: flex;
			flex-direction: column;
			align-items: center;
			padding-top: 20rpx;

			text {
				font-size: 26rpx;
				line-height: 50rpx;
				text-align: center;
			}

			image {
				width: 40rpx;
				height: 40rpx;
			}
		}
	}

	.bottom {
		display: flex;
		flex-wrap: wrap;
		background-color: #fff;
		border-radius: 20rpx;
		margin-top: 60rpx;
		padding-top: 100rpx;

		.item {
			display: flex;
			flex-direction: column;
			align-items: center;

			width: 33.3%;
			height: 200rpx;

			text {
				font-size: 26rpx;
				line-height: 120rpx;
				text-align: center;
			}

			image {
				width: 50rpx;
				height: 50rpx;
			}
		}
	}
</style>
